Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@zendeskgarden/react-selection
Advanced tools
Utilities and render prop containers relating to selection within the Garden Design System.
This package contains utilities and components related to selection in the Garden Design System.
npm install @zendeskgarden/react-selection
# Peer Dependencies - Also Required
npm install react react-dom prop-types styled-components @zendeskgarden/react-theming
This package contains several selection components that use the render prop (child-as-a-function) design pattern.
This allows the consumer to create accessible, performant interactions against any UI Components. Regardless of whether they are wrapped in a specific higher-order-component or styling.
This API style is very structured and is meant as an abstraction for Garden to be able to provide simple APIs while still allowing the possibility for consumers to eject into a render prop container for any advanced usages.
View the React render prop documentation for a more in-depth example of usage.
import { KeyboardFocusContainer } from '@zendeskgarden/react-components';
<KeyboardFocusContainer>
{({ getFocusProps, keyboardFocused }) => (
<button {...getFocusProps()}>
{keyboardFocused ? 'Keyboard focused!' : 'Not keyboard focused'}
</button>
)}
</KeyboardFocusContainer>;
All render prop components within Garden follow this structure:
Container
SelectionContainer
, MenuContainer
, etc.render
prop as well as the children
prop<Container>
{({ getItemProps() }) => (
<div {...getItemProps()}>Test</div>
)}
</Container>
// is the same as
<Container
render={({ getItemProps() }) => (
<div {...getItemProps()}>Test</div>
)}
/>
Uncontrolled
and Controlled
state managementUncontrolled
Controlled
onStateChange
callback to allow the consumer to fully controll the state.
// Uncontrolled Usage
<Container>
{({ getTriggerProps, numClicks }) => <button {...getTriggerProps()}>Clicks {numClicks}</button>}
</Container>;
// Controlled Usage
initialState = {
numClicks: 5
};
<Container numClicks={state.numClicks} onStateChange={newState => setState(newState)}>
{({ getTriggerProps, numClicks }) => <button {...getTriggerProps()}>Clicks {numClicks}</button>}
</Container>;
event.preventDefault()
calls
and overrides you provide.<Container>
{({ getTriggerProps, numClicks }) => (
<button
{...getTriggerProps({
onClick: event => {
/**
* This onClick event will be called before being passed to
* the onClick defined within the example container
*/
alert('clicked');
/**
* Possible to not allow the event to continue
*/
// event.preventDefault();
},
autofocus // We want to use HTML5 autofocus
})}
>
Clicks {numClicks}
</button>
)}
</Container>
FAQs
Utilities and render prop containers relating to selection within the Garden Design System.
The npm package @zendeskgarden/react-selection receives a total of 1,147 weekly downloads. As such, @zendeskgarden/react-selection popularity was classified as popular.
We found that @zendeskgarden/react-selection demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.